/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package daos;

import beans.Bean;
import beans.NovedadBean;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author Milene
 */
public class MSSQLNovedadesDao extends MSSQLDao implements Dao{

    public MSSQLNovedadesDao() throws Exception {
        super();
    }
    
    public MSSQLNovedadesDao(String db) throws Exception {
        super(db);
    }
    
    @Override
    public Bean make(ResultSet result) throws Exception {
        NovedadBean novedad = new NovedadBean();    
        
        novedad.setDescripcion(result.getString("descripcion"));   
        novedad.setAutor(result.getString("nombre")); 
        novedad.setFecha(result.getDate("fecha")); 
       
        return novedad;  
         
        //toma los nombres de las columnas que devuelve los procedimientos
    }

    @Override
    public int insert(Bean bean) throws Exception {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public void update(Bean bean) throws Exception {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public void delete(Bean bean) throws Exception {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public List<Bean> select(Bean bean) throws Exception {
       
        ResultSet result;
        List<Bean> novedades = new ArrayList<Bean>();
        this.setStatement("get_novedades_os"); // agregar el parametro al procedimiento
        result = this.getStatement().executeQuery();        
        
        
        while (result.next()) {

            novedades.add(this.make(result));
        }

        return novedades;
    }

    @Override
    public boolean valid(Bean bean) throws Exception {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }


    @Override
    public long getSize(Bean bean) throws Exception {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    
 
    public Bean get(Bean bean) throws Exception {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    
}
